﻿package mortal.game.control
{
    import Message.Game.*;
    import mortal.component.window.*;
    import mortal.game.mvc.*;
    import mortal.game.view.fashionOnline.*;
    import mortal.game.view.fashionOnline.util.*;
    import mortal.game.view.fashionOnline.view.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class FashionOnlineController extends Controller
    {
        private var _fashionOnlineModule:FashionOnlineModule;

        public function FashionOnlineController()
        {
            return;
        }// end function

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.FashionOnlineFashionUpdate, this.onFashionRewardUpdate);
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._fashionOnlineModule == null)
            {
                this._fashionOnlineModule = new FashionOnlineModule();
                this._fashionOnlineModule.addEventListener(WindowEvent.SHOW, this.onWindowShow);
                this._fashionOnlineModule.addEventListener(WindowEvent.CLOSE, this.onWindowClose);
            }
            return this._fashionOnlineModule;
        }// end function

        private function onWindowShow(event:WindowEvent) : void
        {
            return;
        }// end function

        private function onWindowClose(event:WindowEvent) : void
        {
            return;
        }// end function

        private function onFashionRewardUpdate(param1:SOnlineRewardInfo) : void
        {
            if (this._fashionOnlineModule && this._fashionOnlineModule.currentPanel)
            {
                (this._fashionOnlineModule.currentPanel as FashionOnlineDisplayPanel).updateUI();
            }
            if (FashionOnlineUtil.hasFashionCanTake())
            {
                FashionOnlineIcon.instance.playEffect();
            }
            else
            {
                FashionOnlineIcon.instance.stopEffect();
            }
            return;
        }// end function

    }
}
